﻿using System;
using ch09.binary.module;
using ch09.binary.type;

namespace ch09.binary.interpreter
{
    using WasmVal = Object;

    public delegate WasmVal[] SharpFunc(WasmVal[] args);

    public struct VmFunc
    {
        public FuncType Type;
        public Code Code;
        public SharpFunc SharpFunc;

        public static VmFunc NewExternalFunc(FuncType ft, SharpFunc gf)
        {
            return new VmFunc
            {
                Type = ft,
                SharpFunc = gf,
            };
        }

        public static VmFunc NewInternalFunc(FuncType ft, Code code)
        {
            return new VmFunc
            {
                Type = ft,
                Code = code,
            };
        }
    }
}